package www.admin.mybatis;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class PageResult {

	public Integer getPage() {
		return page;
	}

	public void setPage(Integer page) {
		this.page = page;
	}

	public Integer getTotal() {
		return total;
	}

	public void setTotal(Integer total) {
		this.total = total;
	}

/*	public void setRows(List<? extends Object> result){
		if (result == null || result.isEmpty()) {
			return;
		}
		rows = new ArrayList<Map<String, Object>>();
		for (Object obj : result) {
			Map<String, Object> row = new HashMap<String, Object>();	
			 for (Field f:obj.getClass().getDeclaredFields()){ 
				 f.setAccessible(true); 
				try {
					row.put(f.getName(),f.get(obj));
				} catch (Exception e) {
					e.printStackTrace();
				}
			 }
			rows.add(row);
		}

	}*/
	
	public void setRows(List<Map<String, Object>> result) {
		if (result == null || result.isEmpty()) {
			return;
		}
		rows = new ArrayList<Map<String, Object>>();
		for (Map<String, Object> map : result) {
			Map<String, Object> row = new HashMap<String, Object>();
			for (String key : map.keySet()) {
				row.put(key,map.get(key));
			}
			rows.add(row);
		}
	}
	
	

	public List<Map<String, Object>> getRows() {
		return rows;
	}



	private Integer page;

	private Integer total;

	private List<Map<String, Object>> rows;

}
